<template>
	<view class="">
		<view class="wrap">
			<u-form :model="model" :rules="rules" ref="uForm" :errorType="errorType">
				<view class="tibox">
					<!--标题-->
					<u-form-item label-width="150" :label-position="labelPosition" label="标题" required>
						<u-input :border="border" placeholder="请输入标题(必填)" v-model="model.title" type="text"></u-input>
					</u-form-item>
					
					<u-form-item :label-position="labelPosition" label="小区名称" prop="villageName" label-width="180"
						:leftIconStyle="{color:'#d5d5d5'}">
						<div @click="clickUniMap()" style="margin-right: 30rpx;">地图选择</div>
						<u-input :border="border" type="text" :select-open="selectShow" v-model="model.villageName"
							placeholder="请选择小区(必选)"></u-input>
					</u-form-item>
					<!-- 所在地区 -->
					<u-form-item required label-width="150" :border-bottom="false" prop="villageCity" label="所在地区">
						<div @click="showPicker()" style="margin-right: 30rpx;">选择</div>
						<u-input v-model="model.villageCity" />
					</u-form-item>
					
					<u-form-item label-width="150" :label-position="labelPosition" label="面积" required>
						<u-input :border="border" placeholder="请输入面积(m2)" v-model="model.houseArea" type="number"></u-input>
					</u-form-item>
				</view>
				

				<view class="tibox">
					<u-form-item label-width="150" :label-position="labelPosition" label="期望价格" required>
						<u-input :border="border" placeholder="请输入售价(万)" v-model="model.price" type="number"></u-input>
					</u-form-item>
					
					<u-form-item :label-position="labelPosition" label="户型" label-width="150" required>
						<u-input :border="border" type="select" :select-open="selectShow2" v-model="houseTypeVo"
							placeholder="请选择户型" @click="selectShow2 = true"></u-input>
					</u-form-item>
					
					<!--楼层-->
					<u-form-item :label-position="labelPosition" label="楼层" label-width="150" required>
						<u-input :border="border" type="select" :select-open="floorShow" v-model="model.floor"
							placeholder="请选择楼层" @click="floorShow = true"></u-input>
					</u-form-item>
					<!--朝向-->
					<u-form-item label-width="150" :label-position="labelPosition" label="朝向">
						<u-input :border="border" type="select" :select-open="directionShow" v-model="directionVo"
							placeholder="请选择朝向" @click="directionShow = true"></u-input>
					</u-form-item>
				</view>

				<view class="tibox">
					<u-form-item label-width="180" :label-position="labelPosition" label="装修完成时间">
						<view class="dateBtn" @click="dateClick">
							{{dateLabel}}<u-icon name="arrow-right"></u-icon>
						</view>
					</u-form-item>
					
					<u-form-item :label-position="labelPosition" label="装修情况" prop="decoration" label-width="180"
						:leftIconStyle="{color:'#d5d5d5'}">
						<u-input :border="border" type="select" placeholder="请选择装修(必选)" :select-open="decorationShow"
							v-model="model.decoration" @click="decorationShow = true"></u-input>
					</u-form-item>
				</view>

			
			<view class="tibox">
				<u-form-item :label-position="labelPosition" label="房源图片" label-width="150" required>
					<u-upload :custom-btn="true" ref="uUpload" :auto-upload="true" :file-list="imageList"
						:header="{ accessToken: storage.getAccessToken() }" :action="action"
						:max-size="10 * 1024 * 1024" max-count="9" :size-type="['original']">
						<view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
							<u-icon name="plus" size="60" :color="$u.color['lightColor']"></u-icon>
						</view>
					</u-upload>
				</u-form-item>
			</view>

				

				<!-- 其他补充表单项 -->
				<view v-show="agent">

					<!--          语音介绍-->
					<!--          <u-form-item :label-position="labelPosition" label="语音介绍" label-width="150" required>-->
					<!--            <u-upload-->
					<!--                :custom-btn="true"-->
					<!--                ref="uUploadVoice"-->
					<!--                :auto-upload="true"-->
					<!--                :file-list="voiceList"-->
					<!--                :header="{ accessToken: storage.getAccessToken() }"-->
					<!--                :action="action"-->
					<!--                :max-size="10 * 1024 * 1024"-->
					<!--                max-count="1"-->
					<!--                :accept="'.mp3,.wav,.amr'"-->
					<!--            >-->
					<!--            <view slot="addBtn" class="slot-btn" @click="chooseVoiceFile"> &lt;!&ndash; 绑定独立点击事件 &ndash;&gt;-->
					<!--              <u-icon name="microphone" size="60" :color="$u.color['lightColor']"></u-icon>-->
					<!--            </view>-->
					<!--            </u-upload>-->
					<!--          </u-form-item>-->

					<!--          房东姓名-->
					<u-form-item :label-position="labelPosition" label="房东姓名" prop="ownerName" label-width="180"
						:leftIconStyle="{color:'#d5d5d5'}">
						<u-input :border="border" placeholder="请输入房东姓名(必填)" v-model="model.ownerName"
							type="text"></u-input>
					</u-form-item>
					<u-form-item :label-position="labelPosition" label="房东电话" prop="owerPhone" label-width="180"
						:leftIconStyle="{color:'#d5d5d5'}">
						<u-input :border="border" placeholder="请输入房东电话(必填)" v-model="model.owerPhone" type="number"
							maxlength="11"></u-input>
					</u-form-item>

					<!--物业费-->
					<u-form-item label-width="150" :label-position="labelPosition" label="物业费" required>
						<u-input :border="border" placeholder="请输入物业费(元/月)" v-model="model.propertyFee"
							type="text"></u-input>
					</u-form-item>

					<!--物业公司-->
					<u-form-item label-width="150" :label-position="labelPosition" label="物业公司" required>
						<u-input :border="border" placeholder="请输入物业公司" v-model="model.propertyCompany"
							type="text"></u-input>
					</u-form-item>

					<!--绿化率-->
					<u-form-item label-width="150" :label-position="labelPosition" label="绿化率" required>
						<u-input :border="border" placeholder="请输入绿化率" v-model="model.greeningRate"
							type="text"></u-input>
					</u-form-item>

					<!--容积率-->
					<u-form-item label-width="150" :label-position="labelPosition" label="容积率" required>
						<u-input :border="border" placeholder="请输入容积率" v-model="model.plotRatio" type="text"></u-input>
					</u-form-item>

					<!--停车位-->
					<u-form-item label-width="150" :label-position="labelPosition" label="停车位" required>
						<u-input :border="border" placeholder="请输入停车位" v-model="model.parkingSpace"
							type="text"></u-input>
					</u-form-item>

					<!--开发商-->
					<u-form-item label-width="150" :label-position="labelPosition" label="开发商" required>
						<u-input :border="border" placeholder="请输入开发商" v-model="model.developer" type="text"></u-input>
					</u-form-item>


					<!--房源亮点-->
					<u-form-item label-width="150" :label-position="labelPosition" label="房源亮点" required>
						<u-checkbox-group @change="checkboxGroupChange" :width="radioCheckWidth" :wrap="radioCheckWrap">
							<u-checkbox v-model="item.checked" v-for="(item, index) in checkboxList" :key="index"
								:name="item.name">{{ item.name }}</u-checkbox>
						</u-checkbox-group>
					</u-form-item>

					<u-form-item label-width="150" :label-position="labelPosition" label="房源描述">
						<u-input type="textarea" :border="border" placeholder="请填写房屋描述" v-model="model.introduce" />
					</u-form-item>

				</view>
				<!-- 其他补充表单项 -->
				<!--<wsx-picker-check @confirm="confirm" ref="pickerRef" :options="list" v-model="value"></wsx-picker-check>-->

			</u-form>

			<!-- 流量主-腾讯视频广告 -->
			<!--<ad unit-id="adunit-c6cdd74f48eed506" ad-type="video" ad-theme="white"></ad>-->
			<u-select mode="single-column" :list="selectList" v-model="selectShow" @confirm="selectConfirm"></u-select>


			<u-select mode="single-column" :list="decorationList" v-model="decorationShow"
				@confirm="decorationConfirm"></u-select>
			<u-action-sheet :list="actionSheetList" v-model="actionSheetShow"
				@click="actionSheetCallback"></u-action-sheet>

			<!--户型-->
			<u-select mode="mutil-column" :list="selectList2" v-model="selectShow2"
				@confirm="selectConfirm2"></u-select>

			<!--朝向-->
			<u-select mode="single-column" :list="directionList" v-model="directionShow"
				@confirm="directionConfirm"></u-select>

			<!-- 楼层选择 -->
			<u-select mode="single-column" :list="floorList" v-model="floorShow" @confirm="floorConfirm"></u-select>

			<u-calendar v-model="show" :mode="mode" @change="changeDate" max-date="2100-01-01"></u-calendar>

			<uniMap v-if="mapFlag" @close="closeMap" @callback="callBackAddress" />

			<m-city :provinceData="listArea" headTitle="区域选择" ref="cityPicker" @funcValue="getPickerParentValue"
				pickerSize="4">
			</m-city>
		</view>
		<!--    <view class="agreement"  v-if="showType!='check'">-->
		<!--      <checkbox/> 我已阅读并接受《个人信息处理说明协议》-->
		<!--    </view>-->

		<view class="bottom-btn" v-if="showType!='check'">
			<u-button type="primary" @click="submit" class="btn_sure">{{agent?'补充发布':'填报完成'}}</u-button>
		</view>


	</view>
</template>

<script>
	// import wsxPickerCheck from "@/uni_modules/wsx-picker-check/wsx-picker-check.vue"
	import {
		saveHouse,
		updateHouse
	} from "@/api/house.js";
	import uniMap from "@/components/uniMap";
	import city from "@/components/m-city/m-city.vue";
	import {
		findHouseById,
		findVillageList
	} from "@/api/house.js";
	import storage from "@/utils/storage.js";
	import {
		upload
	} from "@/api/common.js";
	export default {
		components: {
			"m-city": city,
			uniMap,
		},
		data() {
			let that = this;
			return {
				storage,
				radioCheckWidth: 'auto',
				radioCheckWrap: false,
				imageList: [],
				voiceList: [],
				// 图片服务器地址
				action: upload,
				mapFlag: false,
				value: [3],
				list: [{
					value: 1,
					label: '苹果'
				}, {
					value: 2,
					label: '香蕉'
				}, {
					value: 3,
					label: '葡萄'
				}, {
					value: 4,
					label: '榴莲'
				}, {
					value: 5,
					label: '百香果'
				}],
				src: 'http://img.sccnn.com/bimg/340/02027.jpg',
				actionSheetShow: false,
				selectShow2: false,
				directionShow: false,
				houseTypeVo: '',
				directionVo: '',
				floorShow: false,
				role: '',
				model: {
					type: 4,
					houseType: '',
					roomLabel: '',
					villageName: '',
					villageId: '',
					address: '',
					houseNo: '',
					//装修
					decoration: '',
					//房东
					ownerName: '',
					//房东电话
					owerPhone: '',
					payType: '',
					createName: '',
					publishId: '',
					state: 0,
					longitude: 0,
					latitude: 0,
					floor: '',
					startDate: '', // 新增装修时间字段
					introduce: '', //房屋描述
					title: '', //标题
					propertyFee: '', //物业费
					propertyCompany: '', //物业公司
					greeningRate: '', //绿化率
					plotRatio: '', //容积率
					parkingSpace: '', //车位数
					developer: '', //开发商
					voice: '',
					agent: this.agent,
					villageCity: ''
				},
				selectList: [],
				directionList: [{
						value: '东',
						label: '东'
					},
					{
						value: '南',
						label: '南'
					},
					{
						value: '西',
						label: '西'
					},
					{
						value: '北',
						label: '北'
					},
				],
				decorationList: [{
						label: '简装',
						value: '简装'
					},
					{
						label: '中装',
						value: '中装'
					},
					{
						label: '精装修',
						value: '精装修'
					},
					{
						label: '豪装',
						value: '豪装'
					}
				],
				selectList2: [
					[{
							value: '一室',
							label: '一室'
						},
						{
							value: '二室',
							label: '二室'
						},
						{
							value: '三室',
							label: '三室'
						},
						{
							value: '四室',
							label: '四室'
						}
					],
					[{
							value: '',
							label: ''
						},
						{
							value: '一厅',
							label: '一厅'
						},
						{
							value: '二厅',
							label: '二厅'
						},
						{
							value: '三厅',
							label: '三厅'
						}
					],
					[{
							value: '',
							label: ''
						},
						{
							value: '一卫',
							label: '一卫'
						},
						{
							value: '二卫',
							label: '二卫'
						}
					],
				],
				actionSheetList: [{
						text: '月付'
					},
					{
						text: '季付'
					},
					{
						text: '半年付'
					},
					{
						text: '年付'
					}
				],
				floorList: [],
				checkboxList: [{
						name: '大户型',
						checked: false,
						disabled: false
					},
					{
						name: '小户型',
						checked: false,
						disabled: false
					},
					{
						name: '新房',
						checked: false,
						disabled: false
					},
					{
						name: '次新房',
						checked: false,
						disabled: false
					},
					{
						name: '学区房',
						checked: false,
						disabled: false
					},
					{
						name: '自建房',
						checked: false,
						disabled: false
					},
					{
						name: '毛坯房',
						checked: false,
						disabled: false
					},
					{
						name: '精装修',
						checked: false,
						disabled: false
					},
					{
						name: '小高层',
						checked: false,
						disabled: false
					},
					{
						name: '高层房',
						checked: false,
						disabled: false
					},
					{
						name: '电梯洋房',
						checked: false,
						disabled: false
					},
					{
						name: '顶层复式',
						checked: false,
						disabled: false
					},
					{
						name: '一层复式',
						checked: false,
						disabled: false
					},
					{
						name: '东边户',
						checked: false,
						disabled: false
					},
					{
						name: '西边户',
						checked: false,
						disabled: false
					},
					{
						name: '双卫',
						checked: false,
						disabled: false
					},
					{
						name: '一卫',
						checked: false,
						disabled: false
					},
					{
						name: '满二唯一',
						checked: false,
						disabled: false
					},
					{
						name: '满五唯一',
						checked: false,
						disabled: false
					},
					{
						name: '南北朝向',
						checked: false,
						disabled: false
					},
					{
						name: '东西朝向',
						checked: false,
						disabled: false
					},
					{
						name: '总价低',
						checked: false,
						disabled: false
					},
					{
						name: '单价低',
						checked: false,
						disabled: false
					},
					{
						name: '零首付',
						checked: false,
						disabled: false
					},
					{
						name: '低首付',
						checked: false,
						disabled: false
					},
					{
						name: '品牌开发商',
						checked: false,
						disabled: false
					},
					{
						name: '交通便利',
						checked: false,
						disabled: false
					},
					{
						name: '绿化率高',
						checked: false,
						disabled: false
					},
					{
						name: '车位充足',
						checked: false,
						disabled: false
					},
					{
						name: '临医院',
						checked: false,
						disabled: false
					},
					{
						name: '近商业中心',
						checked: false,
						disabled: false
					},
					{
						name: '临公园',
						checked: false,
						disabled: false
					}
				],
				rules: {
					villageCity: [{
						required: true,
						message: '请选择区域',
						trigger: ['change', 'blur'],
					}],
					villageName: [{
						required: true,
						message: '请选择小区',
						trigger: ['change', 'blur'],
					}],
					address: [{
						required: true,
						message: '请输入详细地址',
						trigger: ['change', 'blur'],
					}],
					houseNo: [{
						required: true,
						message: '请输入门牌号',
						trigger: ['change', 'blur'],
					}],
					decoration: [{
						required: true,
						message: '请选择装修',
						trigger: ['change', 'blur'],
					}],
					ownerName: [{
						required: true,
						message: '请输入房东姓名',
						trigger: ['change', 'blur'],
					}],
					owerPhone: [{
						required: true,
						message: '请输入房东电话',
						trigger: ['change', 'blur'],
					}],
					payType: [{
						required: true,
						message: '请选择付款方式',
						trigger: ['change', 'blur'],
					}],
					featureList: [{
						required: true,
						message: '请至少选择一个房源亮点',
						trigger: ['change', 'blur'],
					}],
					floor: [{
						required: true,
						message: '请选择楼层',
						trigger: ['change', 'blur'],
					}]
				},
				border: false,
				check: false,
				selectShow: false,
				decorationShow: false,
				labelPosition: 'left',
				errorType: ['toast'],
				dateLabel: '',
				show: false,
				showType: '',
				agent: '',
				listArea: [{
					id: "",
					localName: "请选择",
					children: [],
				}, ],
			};
		},
		mounted() {
			if (this.$options.filters.tipsToLogin()) {

			}

		},
		onLoad(option) {
			let houseId = option.houseId //上个页面传递的参数。
			if (undefined != option.agent) {
				this.agent = option.agent
			}

			if (undefined != option.role) {
				this.role = option.role
			}
			this.showType = option.showType
			if (houseId) {
				// 渲染当前房源信息
				this.findHouseById(houseId);
			}
			//this.findVillageList()

			// 定位经纬度
			uni.getLocation({
				type: 'gcj02',
				// 当指定 high 时，期望精度值为100m，当指定 best 时期望精度值为20m
				accuracy: 'best',
				// 开启高精度定位
				isHighAccuracy: true,
				success: (res) => {
					this.longitude = res.longitude
					this.latitude = res.latitude
				}
			});
			uni.$on('changeAddressConfig', (address, lon, lat) => {
				// 获取数据
				this.changeAddressConfig(address, lon, lat);
			})
			for (let i = 1; i <= 30; i++) {
				this.floorList.push({
					value: `${i}层`,
					label: `${i}层`
				});
			}
		},
		onUnload() {
			// 移除监听事件
			uni.$off('changeAddressConfig');
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		methods: {
			getPickerParentValue(e) {

				// 检查 model 是否为空，若为空则初始化
				if (!this.model) {
					this.model = {};
				}
				this.model.storeAddressIdPath = [];
				console.log(e)
				let name = "";
				e.forEach((item, index) => {
					if (item.id) {
						// 遍历数据
						this.model.storeAddressIdPath.push(item.id);
						if (index == e.length - 1) {
							name += item.localName;
						} else {
							name += item.localName + ",";
						}
						//  this.model.villageCity = name
						this.$set(this.model, 'villageCity', name)
					}
				});

				// this.form.storeCenter = e[e.length-1].center
			},
			// 显示三级地址联动
			showPicker() {
				this.$refs.cityPicker.show();
			},
			// 替换原有的 chooseVoiceFile 方法
			chooseVoiceFile() {
				uni.chooseMessageFile({
					count: 1,
					type: 'audio', // 强制选择音频
					success: (res) => {
						const tempFile = res.tempFiles[0];
						if (tempFile) {
							this.uploadVoice(tempFile.path);
						}
					},
					fail: (err) => {
						console.error('选择语音失败:', err);
						uni.showToast({
							title: '选择语音失败',
							icon: 'none'
						});
					}
				});
			},

			checkboxGroupChange(e) {
				let featureList = e.map(val => {
					return {
						feature: val
					}
				})
				this.model.featureList = featureList
			},
			// 关闭地图
			closeMap() {
				this.mapFlag = false;
			},
			// 打开地图并访问权限
			clickUniMap() {
				// #ifdef APP-PLUS
				if (plus.os.name == "iOS") {
					// ios系统
					permision.judgeIosPermission("location") ?
						(this.mapFlag = true) :
						this.refuseMap();
				} else {
					// 安卓
					this.requestAndroidPermission(
						"android.permission.ACCESS_FINE_LOCATION"
					);
				}
				// #endif

				// #ifndef APP-PLUS
				this.mapFlag = true;
				// #endif
			},

			// 如果拒绝权限 提示区设置
			refuseMap() {
				uni.showModal({
					title: "温馨提示",
					content: "您已拒绝定位,请开启",
					confirmText: "去设置",
					success(res) {
						if (res.confirm) {
							//打开授权设置
							// #ifndef MP-WEIXIN
							uni.getSystemInfo({
								success(res) {
									if (res.platform == "ios") {
										//IOS
										plus.runtime.openURL("app-settings://");
									} else if (res.platform == "android") {
										//安卓
										let main = plus.android.runtimeMainActivity();
										let Intent = plus.android.importClass(
											"android.content.Intent"
										);
										let mIntent = new Intent("android.settings.ACTION_SETTINGS");
										main.startActivity(mIntent);
									}
								},
							});
							// #endif
						}
					},
				});
			},

			// 获取安卓是否拥有地址权限
			async requestAndroidPermission(permisionID) {
				var result = await permision.requestAndroidPermission(permisionID);

				if (result == 1) {
					this.mapFlag = true;
				} else {
					this.refuseMap();
				}
			},

			// 选择地址后数据的回调
			callBackAddress(val) {
				console.log(val)
				// uni.showLoading({
				//   title: "加载中",
				// });
				console.info("选择地址后数据的回调" + val)
				if (val.regeocode && val) {
					let address = val.regeocode;
					//val.regeocode.addressComponent.district
					this.model.address = address.formatted_address
					//  console.info(address+ this.address);
					this.model.villageName = val.name;
					// console.info("villageName====="+ this.villageName);
					this.model.villageCity = address.addressComponent.province + address.addressComponent.city + address
						.addressComponent.district
					//console.info("villageCity====="+this.villageCity);
					// this.form.detail = address.formatted_address; //地址详情
					// this.form.___path = val.data.result.name;
					// this.form.consigneeAddressIdPath = val.data.result.id; // 地址id分割
					// this.form.consigneeAddressPath = val.data.result.name; //地址名称， '，'分割
					this.model.latitude = val.latitude; //纬度
					this.model.longitude = val.longitude; //经度
					uni.hideLoading();
				}

				this.mapFlag = !this.mapFlag; //关闭地图
			},
			changeAddressConfig(address, lon, lat) {
				this.model.address = address
				this.model.longitude = lon
				this.model.latitude = lat
			},
			submit() {

				let files = [];
				// 通过filter，筛选出上传进度为100的文件(因为某些上传失败的文件，进度值不为100，这个是可选的操作)
				files = this.$refs.uUpload.lists.filter(val => {
					return val.progress == 100;
				})

				if (this.$u.test.isEmpty(files)) {
					uni.showToast({
						title: "请至少选择一张房源图片",
					});
					return
				}
				let imageList = files.map(val => {
					if (undefined != val.response) {
						return {
							imageName: '',
							imagePath: '',
							imgUrl: val.response.result,
							imageSize: 0
						}
					}
				})
				this.model.imageList = imageList
				this.model.agent = this.agent
				//
				// let files2 = [];
				// // 通过filter，筛选出上传进度为100的文件(因为某些上传失败的文件，进度值不为100，这个是可选的操作)
				// files2 = this.$refs.uUploadVoice.lists.filter(val => {
				//   return val.progress == 100;
				// })
				// let voiceList = files2.map(val => {
				//   if (undefined != val.response) {
				//     return {
				//       imageName: '',
				//       imagePath: '',
				//       imgUrl: val.response.result,
				//       imageSize: 0
				//     }
				//   }
				// })
				//
				// if(voiceList.length>0){
				//   this.model.voice=voiceList[0].imgUrl
				// }

				if (this.$u.test.isEmpty(this.model.villageName)) {
					uni.showToast({
						title: "请输入小区名称",
					});
					return
				}
				if (this.$u.test.isEmpty(this.model.houseArea)) {
					uni.showToast({
						title: "请输入房屋面积",
					});
					return
				}

				if (this.$u.test.isEmpty(this.model.price)) {
					uni.showToast({
						title: "请输入售价",
					});
					return
				}
				if (this.$u.test.isEmpty(this.model.villageCity)) {
					uni.showToast({
						title: "请选择区域",
					});
					return
				}

				this.model.type = 4; //二手房房
				if (this.model.id) {

					updateHouse(this.model).then((result) => {

						this.isButtonDisabled = true;

						// 设置定时器，5秒后重新启用按钮
						this.timer = setTimeout(() => {
							this.isButtonDisabled = false;
						}, 5000);


						this.$u.route({
							url: 'pages/house/order',
						})
					});


				} else {

					saveHouse(this.model).then((result) => {

						if (result.data.code == 200) {
							this.isButtonDisabled = true;

							// 设置定时器，5秒后重新启用按钮
							this.timer = setTimeout(() => {
								this.isButtonDisabled = false;
							}, 5000);

							// uni.navigateTo({
							//   url: `/pages/mine/im/index?talkId=${item.agentUserId}&houseId=`+item.id
							// });

							//   if(undefined==this.agent){
							this.$u.route({
								url: 'pages/house/detail/info?talkId=' + result.data.data.id + "&name1=" +
									result.data.data.name1,
							})
							//  }else{
							//提示添加成功
							uni.showToast({
								title: '添加成功',
							});

							//延时一秒
							// setTimeout(() => {
							//   //返回上一页
							//   uni.navigateBack({
							//     delta: 1
							//   });
							// }, 1000)

							//}


							//this.$options.filters.talkIm(result.data.data.agentUserId, '', '')


						} else {
							uni.showToast({
								title: result.data.msg,
							});
						}

					});

				}


			},
			selectConfirm(e) {
				e.map((val, index) => {
					this.model.villageName = val.label;
					this.model.villageId = val.value
				})
			},
			decorationConfirm(e) {
				e.map((val, index) => {
					this.model.decoration = val.label;
				})
			},
			directionConfirm(e) {
				e.map((val, index) => {
					this.model.direction = val.label;
					this.directionVo = val.label;
				})
			},
			// 选择类型回调
			selectConfirm2(e) {
				this.model.houseType = ''
				e.map((val, index) => {
					if (index == 0) {
						this.model.houseNum = val.label;
					} else if (index == 1) {
						this.model.houseHall = val.label;
					} else if (index == 2) {
						this.model.toiletNum = val.label;
					}
					this.model.houseType += val.label;
					this.houseTypeVo = this.model.houseType
				})
			},
			labelPositionChange(index) {
				this.labelPosition = index == 0 ? 'left' : 'top';
			},
			// 点击actionSheet回调
			actionSheetCallback(index) {
				uni.hideKeyboard();
				this.model.payType = this.actionSheetList[index].text;
			},
			findVillageList() {

				findVillageList({
					city: '',
					orderByColumn: 'name',
					isAsc: 'desc'
				}).then((result) => {

					const data = result.data.rows
					for (let i = 0; i < data.length; i++) {
						// 先转成字符串再转成对象，避免数组对象引用导致数据混乱
						let item = data[i]
						this.selectList.push({
							label: item.name,
							value: item.id
						})
					}
					return data
				});
			},
			findHouseById(houseId) {
				// let url = "api/houseApi/findHouseById";
				// this.$u.get(url, {
				// 	id: houseId
				// }).then(result => {
				findHouseById({
					id: houseId
				}).then((result) => {

					let room = result.data.data
					this.model = room
					let houseType = this.model.houseNum + this.model.houseHall + this.model.toiletNum
					if (houseType == 0) {
						houseType = ''
					}
					this.model.houseType = houseType
					this.houseTypeVo = houseType

					if (this.model.roomType == 1) {
						this.model.roomLabel = '主卧'
					} else if (this.model.roomType == 2) {
						this.model.roomLabel = '次卧'
					}
					this.directionVo = this.model.direction

					// this.fileList = [];

					if (null != room.imageList) {
						room.imageList.forEach(item => {
							var vo = {
								url: item.imgUrl
							}
							this.imageList.push(vo);
						})

					}
					// if(null!=room.voiceList){
					//   room.voiceList.forEach(item => {
					//     var vo = {
					//       url: item.imgUrl
					//     }
					//     this.voiceList.push(vo);
					//   })
					// }


					// 回显房源亮点
					if (room.featureList) {
						this.checkboxList.forEach(item => {
							this.model.featureList.forEach(feature => {
								if (feature.feature == item.name) {
									item.checked = true
								}
							})
						})
						//this.directionVo = newName.direction
					}

				});
			},
			chooseAddress() {
				this.$u.route({
					url: '/pages/chooseAddress/index'
				})
			},
			floorConfirm(e) {
				e.map((val, index) => {
					this.model.floor = val.label;
				})
			},
			dateClick() {
				this.show = true
			},
			changeDate(e) {
				this.model.startDate = e.result
				this.dateLabel = e.result
			}
		}
	};
</script>

<style>
	page {
		background-color: #FFFFFF;
		padding-bottom: 80rpx;
	}
</style>
<style scoped lang="scss">
	page {
		background-color: rgb(245, 245, 245);
		// padding: 32rpx;
	}
	.wrap {
		// top: 10%;
		padding: 30rpx;
		
		.tibox {
			width: 100%;
			background-color: #FFF;
			border-radius: 16rpx;
			padding: 0 32rpx;
			margin-bottom: 24rpx;
		}
	}

	.bottom-btn {
		position: fixed;
		bottom: 8rpx;
		right: 0;
		left: 0;
		width: 100%;
		padding: 30rpx;
		z-index: 10;
		
		.btn_sure{
			background: linear-gradient(to left,rgb(49, 130, 255),rgb(145, 188, 255));
			border-radius: 52rpx;
		}
	}

	/* #endif */

	///* #ifndef MP-WEIXIN */
	//.bottom-btn {
	//  padding: 0 30rpx 30rpx 30rpx;
	//  background-color: #FFFFFF;
	//}
	///* #endif */


	//.u-checkbox-group {
	//  display: grid;
	//  grid-template-columns: repeat(6, 1fr);
	//  gap: 15rpx;
	//  padding: 10rpx 0;
	//}
	//
	//.u-checkbox {
	//  padding: 12rpx;
	//  border-radius: 8rpx;
	//  background-color: #f8f9fa;
	//}
	//
	//.u-checkbox__input:checked + .u-checkbox__label {
	//  color: #007AFF;
	//}

	.dateBtn {
		position: absolute;
		right: 0rpx;
		top: 10rpx;
		color: #606266;
	}

	.agreement {
		margin-bottom: 20px;
		margin-left: 4%;
	}


	.slot-btn {
		width: 160rpx;
		height: 160rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: rgb(244, 245, 246);
		border-radius: 10rpx;
	}

	.slot-btn__hover {
		background-color: rgb(235, 236, 238);
	}

	.custom-gap {
		width: 1000rpx;
		height: 10rpx;
		margin: 0 -200rpx 0 -200rpx;
		background-color: rgb(235, 236, 238);
	}
</style>